// The uploadStart event handler.  This function variable is assigned to upload_start_handler in the settings object

function uploadProgress(file, bytesLoaded, bytesTotal) {

	 try { 

	       var percent = Math.ceil((bytesLoaded / bytesTotal) * 100); 

	      var progress= new FileProgress(file, this.customSettings.progressTarget); 
	       progress.setProgress(percent); 
	       progress.setStatus( " 已上传 " + percent+ "% ......" ); 

	    } catch (ex) { 

	       this .debug(ex); 

	    } 


}
function fileDialogStart() {
	var pt=document.getElementById(this.customSettings.progressTarget);
	var childs = pt.childNodes;    
	  for(var i = childs.length - 1; i >= 0; i--) {      
		  pt.removeChild(childs[i]);      
	  }  

}
function fileQueued(file) {
	
}
function fileQueueError(file, errorCode, message)
{
	try {
		if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) {
			alert("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file.")));
			return;
		}

		var progress = new FileProgress(file, this.customSettings.progressTarget);
		progress.setError();
		progress.toggleCancel(false);

		switch (errorCode) {
		case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
			progress.setStatus("文件不能大于1M");
			this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
			progress.setStatus("无法上传0字节文件.");
			this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE:
			progress.setStatus("无效文件类型.");
			this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
			alert("You have selected too many files.  " +  (message > 1 ? "You may only add " +  message + " more files" : "You cannot add any more files."));
			break;
		default:
			if (file !== null) {
				progress.setStatus("未知错误");
			}
			this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message);
			break;
		}
	} catch (ex) {
        this.debug(ex);
    }
}
// The uploadSuccess event handler.  This function variable is assigned to upload_success_handler in the settings object


// The uploadError event handler.  This function variable is assigned to upload_error_handler in the settings object
function uploadError(file, errorCode, message) {

}
function uploadComplete(file) {
	try {
		if (this.getStats().files_queued === 0) {
		} else {
			this.startUpload();
		}
	} catch (ex) {
		this.debug(ex);
	}
}

